Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli/command/stack: fix faulty sort for sorting stacks #5212

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

thaJeztah
Copy link
Member

This code was updated in 7b9580d (#3139), which removed support for using kubernetes as orchestrator, but in doing so made this sort.Slice (probably) not do what it was expected to do ':)

index 412cc2e5ee86..861ae1be2fb9 100644
@@ -75,8 +54,7 @@ func format(dockerCli command.Cli, opts options.List, orchestrator command.Orche
 	}
 	sort.Slice(stacks, func(i, j int) bool {
 		return sortorder.NaturalLess(stacks[i].Name, stacks[j].Name) ||
-			!sortorder.NaturalLess(stacks[j].Name, stacks[i].Name) &&
-				sortorder.NaturalLess(stacks[j].Namespace, stacks[i].Namespace)
+			!sortorder.NaturalLess(stacks[j].Name, stacks[i].Name)
 	})
 	return formatter.StackWrite(stackCtx, stacks)
 }

The extra condition was added in 84241cc (#1031) to support multiple namespaces. This patch removes it, bringing it back to the state it was before that commit.

- A picture of a cute animal (not mandatory but encouraged)

This code was updated in 7b9580d, which
removed support for using kubernetes as orchestrator, but in doing so
made this `sort.Slice` (probably) not do what it was expected to do ':)

    index 412cc2e5ee86..861ae1be2fb9 100644
    @@ -75,8 +54,7 @@ func format(dockerCli command.Cli, opts options.List, orchestrator command.Orche
        }
        sort.Slice(stacks, func(i, j int) bool {
            return sortorder.NaturalLess(stacks[i].Name, stacks[j].Name) ||
    -            !sortorder.NaturalLess(stacks[j].Name, stacks[i].Name) &&
    -            sortorder.NaturalLess(stacks[j].Namespace, stacks[i].Namespace)
    +            !sortorder.NaturalLess(stacks[j].Name, stacks[i].Name)
        })
        return formatter.StackWrite(stackCtx, stacks)
     }

The extra condition was added in 84241cc
to support multiple namespaces. This patch removes it, bringing it back to
the state it was before that commit.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah added this to the 28.0.0 milestone Jul 1, 2024
@thaJeztah thaJeztah requested review from silvin-lubecki and a team as code owners July 1, 2024 11:21
@thaJeztah thaJeztah self-assigned this Jul 1, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.42%. Comparing base (4270341) to head (be14edc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5212      +/-   ##
==========================================
- Coverage   61.43%   61.42%   -0.01%     
==========================================
  Files         298      298              
  Lines       20799    20798       -1     
==========================================
- Hits        12777    12776       -1     
  Misses       7109     7109              
  Partials      913      913              

@thaJeztah thaJeztah merged commit cd982b1 into docker:master Jul 1, 2024
103 checks passed
@thaJeztah thaJeztah deleted the fix_stack_sorting branch July 1, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants